#include <stdio.h>  
#include <cuda_runtime.h>  
  
int main() {  
    int dev = 0;  
    cudaDeviceProp devProp;  
    cudaError_t cudaStatus = cudaGetDeviceProperties(&devProp, dev);  
    if (cudaStatus != cudaSuccess) {  
        fprintf(stderr, "cudaGetDeviceProperties failed!  Do you have a CUDA-capable GPU installed?\n");  
        return 1;  
    }  
  
    // 每个SM有128个CUDA Cores 
    int cudaCoresPerSM = 128;  
    int totalCudaCores = devProp.multiProcessorCount * cudaCoresPerSM;  
  
    printf("使用GPU设备 %d: %s\n", dev, devProp.name);  
    printf("SM的数量：%d\n", devProp.multiProcessorCount);  
    printf("CUDA CORE数量：%d\n", totalCudaCores);  
    printf("计算能力（Compute Capability）：%d.%d\n", devProp.major, devProp.minor);  
    printf("显存大小：%.2f GB\n", devProp.totalGlobalMem / 1024.0 / 1024.0 / 1024.0);  
    printf("每个线程块的共享内存大小：%.2f KB\n", devProp.sharedMemPerBlock / 1024.0);  
    printf("每个线程块的最大线程数：%d\n", devProp.maxThreadsPerBlock);  
    printf("每个线程块的最大共享内存（字节）：%ld\n", devProp.sharedMemPerBlock);


    printf("每个warp的线程数：%d\n", devProp.warpSize);  
    printf("每个SM的最大warp数：%d\n", devProp.maxThreadsPerMultiProcessor / devProp.warpSize);  
    printf("每个SM的最大线程块数：%d（近似值，因为线程块大小可变）\n", devProp.multiProcessorCount);  
    printf("每个SM的最大线程数：%d\n", devProp.maxThreadsPerMultiProcessor);  
    printf("最大线程块大小：(%d, %d, %d)\n",  
          devProp.maxThreadsDim[0], devProp.maxThreadsDim[1], devProp.maxThreadsDim[2]);  
    printf("每个SM的寄存器数：%d\n", devProp.regsPerMultiprocessor);  
    printf("每个线程块的最大寄存器数：%d\n", devProp.regsPerBlock);  
    int maxRegistersPerThread = devProp.regsPerBlock / devProp.maxThreadsPerMultiProcessor;
    printf("每个线程的最大寄存器数：%d\n", maxRegistersPerThread);  
    printf("每个SM的共享内存（字节）：%ld\n", devProp.sharedMemPerMultiprocessor);  

    printf("\n");  
  
    return 0;  
}